home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 342_01.zip / DIOFNC06.C < prev    next >
C/C++ Source or Header  |  1993-04-03  |  2KB  |  68 lines

  1. /*-
  2.  *  ----------------------------------------------------------------------
  3.  *  File        :   DIOFNC06.C
  4.  *  Creator     :   Blake Miller
  5.  *  Version     :   01.01.00        February 1991
  6.  *  Language    :   Microsoft C     Version 5.1
  7.  *  Purpose     :   Intel 8255 Compatible Digital IO Functions
  8.  *                  8255 Get Byte Function
  9.  *  ----------------------------------------------------------------------
  10.  *  Revision History:
  11.  *  022891 BVM  :   Change int to short.
  12.  *  070490 BVM  :   Creation
  13.  *  ----------------------------------------------------------------------
  14.  */
  15.  
  16. #define     DIOFNC06_C_DEFINED  1
  17. #include    "DIOLIB.H"
  18. #undef      DIOFNC06_C_DEFINED
  19.  
  20. void dio_get_byte (DIODAT *data, short port, unsigned char *p_dat);
  21.  
  22. /*- DIO : Byte Get ---------------------------**
  23.  *  Read one of the bytes in the 8255.
  24.  *  The port number should be 0 - 2 as follows:
  25.  *  Use the defines (DIOLIB.H):
  26.  *  DIO_PORTA = 0 = Port A
  27.  *  DIO_PORTB = 1 = Port B
  28.  *  DIO_PORTC = 2 = Port C
  29.  *  Reads the 8255 and returns data in variable as well as
  30.  *  loading port data area.
  31.  *  Passed:
  32.  *      pointer :   DIODAT
  33.  *      short   :   port number
  34.  *      pointer :   unsigned char : returned port data
  35.  *  Returns:
  36.  *      nothing
  37.  *      Loads stat with appropriate error code.
  38.  *      Loads p_dat with returned data.
  39.  */
  40. void dio_get_byte (DIODAT *data, short port, unsigned char *p_dat)
  41.     {
  42.     unsigned char ival;
  43.  
  44.     /*  Make sure the port requested is valid.
  45.      *  Three ports.
  46.      */
  47.     if ( (port < DIO_PORTA) || (port > DIO_PORTC) ){
  48.         data->stat = DIO_ST_BP;
  49.         return;
  50.         }
  51.  
  52.     /*  Input the data.
  53.      *  Save the input data.
  54.      *  Store to return buffer.
  55.      *  Indicate all is okay.
  56.      */
  57.     dio_bget ( data->base + port, &ival );
  58.     data->pdat[port] = ival;
  59.     data->stat = DIO_ST_OK;
  60.     *p_dat = ival;
  61.     }
  62.  
  63. /*-
  64.  *  ----------------------------------------------------------------------
  65.  *  END DIOFNC06.C Source File
  66.  *  ----------------------------------------------------------------------
  67.  */
  68.